
<!doctype html>
<html>
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
		<link href="../css/main.css" type="text/css" rel="stylesheet" />
		<link href="../css/dialog.css" rel="stylesheet" type="text/css">
		<script type="text/javascript" src="../datePicker/WdatePicker.js"></script>
		<title></title>
		<style type="text/css">
		textarea{/* width: 340px; */width: 333px;height: 100px;border: #a6d9da solid 1px;padding: 5px;}
			.textarea1{border:none;resize : none;overflow-y:visible }
		</style>
	</head>
	<body>
		<div class="main_frame">
			<div class="position_div">
				<img src="../images/position_icon.png" />
				<i>系统管理</i><i>&gt;&gt;</i><i>协议接口</i>
			</div>
			<div class="right_div">
				<div class="search_div">
					<div class="label_div">
						<label class="text_label">协议名称：</label>
						<input type="text" class="input_search" placeholder="支持模糊查询" id="qry_name" />
					</div>
					
					
					<div class="done_div">
						<button class="btn_common1 title_div2"  onclick="qryItemListBtn()">
							<i></i>搜索
						</button>
						<button style="margin-left:10px !important" class="btn_common2 newadd"   onclick="toAddForm()">
							<i></i>新增
						</button>
					</div>
                    <div class="cl">&nbsp;</div>
				</div>
				<table class="table_list">
					<tr>
						<th width="6%">序号</th>
						<th width="10%">名称</th>
						<th width="10%">账号</th>
						<th width="10%">秘钥</th>
						<th width="20%">访问地址</th>
						<th width="8%">是否可用</th>
						<th width="20%">备注</th>
						<th class="last_td">操作</th>
					</tr>
					<tbody id="listbox1">
					</tbody>
				</table>
				<div class="turn_page" style="display:none">
				   <div class="main_page" id="pageCon">
					   <a href="javascript:void(0)" class="first_a" id="firstPage"></a>
					   <a href="javascript:void(0)" class="up_a" id="prev"></a>    	
					   <a href="javascript:void(0)" class="next_a" id="next"></a>
					   <a href="javascript:void(0)" class="last_a" id="lastPage"></a>
					   <input id="page_num_input" style="width:40px;" type="text" onblur="checkValue(this);" onkeyup="value=value.replace(/\D/g,'')"/>
					   <button type="button" class="num_input" id="go_num_input">跳转</button>
					   <b class="page_text">当前<i><em id="nowpage"></em>/<em id="totalpage"></em></i>页，总数<i id="totalNum"></i>条</b>    	
				   </div>
				</div>
				
				
				
				
				<div class="opacity_div" style="display: none;"></div>
				<div class="bookDetail" style="display: none;top:150px;">
					<div class="prop_top">
						<i>新增字典</i>
						<a href="javascript:void(0)" class="close_icon"><img src="../images/close_icon.png"></a>
					</div>
					<div class="bookdetail_box">
					<form action="" id="form">
						<div class="blank_div"></div>
						<input type="hidden" class="input_search width_input" name="id" value="0"/>
						<div class="blank_div"></div>
						<label class="text_label label_width">名称：</label>
					    <input type="text" class="input_search width_input notNull" name="name" />
					    &nbsp;&nbsp;<span style="color: red">* </span>
					    					    
					    
					    <div class="blank_div"></div>
					    <label class="text_label label_width">账号：</label>
					    <input type="text" class="input_search width_input notNull" name="account" />
					    &nbsp;&nbsp;<span style="color: red">* </span>
					    
					    <div class="blank_div"></div>
					    <label class="text_label label_width">密钥：</label>
					       <input type="text" class="input_search width_input notNull" name="secretKey" />
					    &nbsp;&nbsp;<span style="color: red">* </span>
					    <div class="blank_div"></div>
					    <label class="text_label label_width">访问地址：</label>
					       <input type="text" class="input_search width_input notNull" name="visitAddress" />
					    &nbsp;&nbsp;<span style="color: red">* </span>
					    <div class="blank_div"></div>
					    <label class="text_label label_width">是否可用：</label>
						<div class="drop_frame">
							<i class="text_i" data-status="y"  >可用</i>
							<span class="span_arrow"></span>
							<input type="hidden" name="usable" value="y" >
							<ul class="choose_ul ">
								<li><a href="javascript:void(0)" class="choose_a" data-status="y">可用</a></li>
								<li><a href="javascript:void(0)" class="choose_a" data-status="n">不可用</a></li>
							</ul>
						</div>
					   
						<div class="blank_div"></div>
					    <label class="text_label label_width">协议说明：</label>
					    <textarea class="textarea notNull" name="description" data-maxLen="100" ></textarea>

					    &nbsp;&nbsp;<span style="color: red">* </span>
						
						
					</form>
					<div class="blank_div"></div>
					<div class="blank_div"></div>
					<div class="bottom_donebtn width_div">
						<button class="btn_common2"  onclick="itemFormSubmit()">提交</button>
						<button class="btn_common1" onclick="edit_cancel()">取消</button>	
					</div>
					
					</div>
					<div class="blank_div"></div>
					<div class="blank_div"></div>
					
				</div>
				
				
			
			
				
				
				
			</div>
		</div>
		<script type="text/javascript" src="../js/jquery-1.10.2.min.js"></script>
		<script type="text/javascript" src="../js/common.js"></script>
		<script type="text/javascript" src="../js/dialog.js"></script>
		<script type="text/javascript" src="../js/jquery-data.js"></script>
		<script type="text/javascript">
		var type_array=["","项目类型","设备类型","故障类型","保养类型"]
			var yema=1;
			var pagelen=10;
			var totalPage=0;   
			function qryList(){		
				qryItemList();
			}
			
			$(document).ready(function(){
				
				qryList();
			});
			function qryList(){
				qryItemList();
			}
			function qryItemListBtn(){
				 yema=1;
				qryItemList();
			}
			function qryItemList(){
				$.ajax({
					url: 'qryProtocolListList', 
					type: 'POST',
					data:{
						name:$("#qry_name").val(),
						yema:yema,length:pagelen},
					async: false,
					dataType: 'json', 
					timeout: 10000, 
					error: function(){LQWarn('请求失败,请稍后重试');}, 
					success: function(result){
						
						if(result.resultCode==1000){
							var items=result.returnObject.pageList;
							if (items && items.length > 0) {
								var rlist="";
								var item ;
								
								$.each(items,function(i){
									item = items[i];
									rlist+='<tr data-status ="'+ item.id+'"><td>'
										+ (i+1+length*(result.returnObject.curPage-1))
										+ '</td><td>' 
										+ item.name
										+ '</td><td>' 
										+ item.account
										+ '</td><td>' 
										+ item.secretKey
										+ '</td><td>' 
										+ item.visitAddress
										+ '</td><td>' 
										+ ("y" == item.usable ? "可用" :"不可用")
										+'</td><td>'
										+ replaceNull(item.description)
										+'</td><td class="last_td">'
										+ '<a class="mod" title="修改" href="javascript:void(0);" onclick="toEditForm(this)">修改</a>'
										+ '<a class="del" title="删除" href="javascript:void(0);" onclick="delItem(this)">删除</a>'
										
										+ '</td></tr>';
								});
								$("#listbox1").html(rlist);
								totalPage=result.returnObject.totalPage;
								$("#nowpage").html(result.returnObject.curPage);
								$("#totalpage").html(totalPage);
								$("#totalNum").html(result.returnObject.totalNum);
								$(".turn_page").show();
							}else{
								$("#listbox1").html("");
								$(".turn_page").hide();
							}
						}
						else if(result.resultCode==1004){
							LQWarn(result.returnObject);
							window.top.location.href ="../login.jsp";
						}else{
							LQWarn(result.returnObject);
						}
					}
				});
			}
			
			var url_ = "addProtocolInfo.do";
			
			function toAddForm(){
				$(".opacity_div,.bookDetail").show();	
				url_ = "addProtocolInfo.do";
				$("#form").clearForm();
			}

			
			function itemFormSubmit(){
			//	console.log($("#form").serialize());
					if($("#form").checkhaveNull()){
					return;
				}
				operateObject(url_,$("#form").serialize(),function(){edit_cancel();});
				//return;
				
			}
			
			
			function toEditForm(obj){
				var id = $(obj).parents("tr").attr("data-status");
				toAddForm();
				url_ = "editProtocolInfo.do";
				getObjectWithFillData("getProtocolInfo.do",{"id":id},$("#form"));
				
			}
			
			function delItem(obj){
				
				var id = $(obj).parents("tr").attr("data-status");
				delObject('delProtocolInfo.do',{"id":id});
				
				
			}
			
			function edit_cancel(){
				$(".opacity_div,.bookDetail").hide();
			}
			
			
				
		</script>
	</body>
</html>
